home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15672 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is wrong with this loop?
  5. Date: Sun, 21 Apr 96 00:08:31 GMT
  6. Organization: none
  7. Message-ID: <830045311snz@genesis.demon.co.uk>
  8. References: <4l86la$1t9@uwm.edu> <4l8apa$kv8@spanky.pls.ov.com> <4lb6sj$c5c@abel.cc.sunysb.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4lb6sj$c5c@abel.cc.sunysb.edu>
  15.            dkat@psych1.psy.sunysb.edu "DK" writes:
  16.  
  17. >
  18. >/* I assume you mean 
  19. >  while (cd != 'm' || cd != 'f' || cd != 'o')
  20. >/*try using gets(line) - it is always safer*/
  21.  
  22. You obviously haven't been reading the newsgroup for very long or the FAQ
  23. for that matter. I refer you to:
  24.  
  25. 12.23:    Why does everyone say not to use gets()?
  26.  
  27. A:    Unlike fgets(), gets() cannot be told the size of the buffer
  28.     it's to read into, so it cannot be prevented from overflowing
  29.     that buffer.  As a general rule, always use fgets().  See
  30.     question 7.1 for a code fragment illustrating the replacement of
  31.     gets() with fgets().
  32.  
  33.     References: Rationale Sec. 4.9.7.2; H&S Sec. 15.7 p. 356.
  34.  
  35. -- 
  36. -----------------------------------------
  37. Lawrence Kirby | fred@genesis.demon.co.uk
  38. Wilts, England | 70734.126@compuserve.com
  39. -----------------------------------------
  40.